﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;

namespace NJL.Web.Visitor
{
    public partial class InviteFriends : BasePageVisitor
    {
        NJL.BLL.NJL_PERSON bllPerson = new BLL.NJL_PERSON();
        NJL.BLL.NJL_MYFRIEND bllFriend = new BLL.NJL_MYFRIEND();
        protected void Page_Load(object sender, EventArgs e)
        {
            DataSet ds = bllPerson.GetListUserInPerson("a.ID!=" + Request.QueryString["uid"] + " and a.NJL_SYS_BASE_ID=" + WEBSITE_CODE);
            string[] par = { "uid" };
            page.InnerHtml = Royalsoft.Common.Pager.GetPageNum(ds, rptFriends, 20, par);
        }
        protected void rptFriends_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Literal lit = e.Item.FindControl("litAttention") as Literal;
                DataRowView drv = (DataRowView)e.Item.DataItem;
                string id = drv["ID"].ToString();
                DataSet dsFriend = bllFriend.GetList("NJL_MYFRIEND.FRIEND_USER_ID=" + id + " and NJL_MYFRIEND.NJL_USER_ID=" + UserId);
                if (UserType == "2")
                {
                    if (dsFriend.Tables[0].Rows.Count > 0)
                    {
                        lit.Text = "<a href=javascript:DeleteUser('" + id + "')>取消关注</a>";
                    }
                    else
                    {
                        lit.Text = "<a href=javascript:AddUser('" + id + "')>添加关注</a>";
                    }
                }

            }
        }
    }
}